/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.cggveritas.crewintranet.jms.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.codehaus.jackson.annotate.JsonIgnore;

/**
 *
 * @author Alassane
 */
@Entity
@Table(name = "right")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Right.findAll", query = "SELECT r FROM Right r"),
    @NamedQuery(name = "Right.findById", query = "SELECT r FROM Right r WHERE r.id = :id"),
    @NamedQuery(name = "Right.findByRight", query = "SELECT r FROM Right r WHERE r.right = :right"),
    @NamedQuery(name = "Right.findByNameRight", query = "SELECT r FROM Right r WHERE r.nameRight = :nameRight")})
public class Right implements Serializable {
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "rightId", fetch = FetchType.LAZY)
    private List<Users> usersList;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "right")
    private String right;
    @Basic(optional = false)
    @Column(name = "nameRight")
    private String nameRight;

    public Right() {
    }

    public Right(Integer id) {
        this.id = id;
    }

    public Right(Integer id, String right, String nameRight) {
        this.id = id;
        this.right = right;
        this.nameRight = nameRight;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getRight() {
        return right;
    }

    public void setRight(String right) {
        this.right = right;
    }

    public String getNameRight() {
        return nameRight;
    }

    public void setNameRight(String nameRight) {
        this.nameRight = nameRight;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Right)) {
            return false;
        }
        Right other = (Right) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fr.cggveritas.crewintranet.jms.entities.Right[ id=" + id + " ]";
    }

    @XmlTransient
    @JsonIgnore
    public List<Users> getUsersList() {
        return usersList;
    }

    public void setUsersList(List<Users> usersList) {
        this.usersList = usersList;
    }
    
}
